package com.tinckay.controller;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.tinckay.entity.po.Task;
import com.tinckay.service.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author: Jean
 * @Desc:
 * @Date: 2018/11/14 16:21
 */
@Api(tags = "当日实情查询")
@RestController
@RequestMapping("/truth")
@RequiresRoles(value = {"admin", "user"}, logical = Logical.OR)
public class CurrDayTruthController extends ApiController {

    @Autowired
    private TaskService taskService;

    @GetMapping("/latestTransport")
    @ApiOperation("车辆实时运输状态")
    //@RequiresPermissions("truth:latestTransport")
    @ApiImplicitParam(name = "vehNo", value = "车牌号码", defaultValue = "", required = true, dataType = "string", paramType = "query")
    public R latestTransport(@RequestParam String vehNo) {
        Map<String, Object> resutl = taskService.latestTransport(vehNo);
        return success(resutl);
    }

    @GetMapping("/vehTranProcess")
    @ApiOperation("当日车辆运输过程")
    //@RequiresPermissions("truth:vehTranProcess")
    @ApiImplicitParam(name = "vehNo", value = "车牌号码", defaultValue = "", required = true, dataType = "string", paramType = "query")
    public R vehTranProcess(@RequestParam String vehNo) {
        List<Task> result = taskService.vehTranProcess(vehNo);
        return success(result);
    }

    @GetMapping("/pourProcessTimeInfo")
    //@RequiresPermissions("truth:pourProcessTimeInfo")
    @ApiOperation("当日已完成浇筑计划过程耗时")
    public R pourProcessTimeInfo() {
        List<Map<String, Object>> result = taskService.pourProcessTimeInfo();
        return success(result);
    }

}
